package com.example.nutritionmanager

import androidx.compose.runtime.Composable
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument

@Composable
fun AppNavHost() {
    val navController = rememberNavController() // 初始化 NavController


    NavHost(navController = navController, startDestination = "splash") {
        composable("splash") { SplashScreen(navController) }
        composable(
            route = "login?showExpiredDialog={showExpiredDialog}",
            arguments = listOf(navArgument("showExpiredDialog") {
                type = NavType.BoolType
                defaultValue = false
            })
        ) { backStackEntry ->
            val showExpiredDialog = backStackEntry.arguments?.getBoolean("showExpiredDialog") ?: false
            LoginScreen(navController, showExpiredDialog)
        }
        composable("register") { RegisterScreen(navController) }
        composable("main") { MainScreen(navController) }
    }
}